package com.sk.sqd.memento.game;

import lombok.Data;

@Data
public class Role {

    /**
     * 攻击
     */
    private Integer attack;

    /**
     * 血量
     */
    private Integer blood;

    /**
     * 防御
     */
    private Integer defense;

    /**
     * 初始化
     */
    public void init() {
        this.defense = 100;
        this.blood = 100;
        this.attack = 5;
    }

    /**
     * 战斗
     */
    public void fight() {
        this.defense = 30;
        this.blood = 20;
        this.attack = 5;
    }

    /**
     * 角色状态查看
     */
    public void show() {
        System.out.println("血量：" + blood + " 攻击：" + attack + " 防御：" + defense);
    }

    /**
     * 保存角色状态
     *
     * @return 角色状态备忘录
     */
    public RoleMemento save() {
        return RoleMemento.builder()
                .blood(blood)
                .attack(attack)
                .defense(defense)
                .build();
    }

    /**
     * 恢复角色状态
     */
    public void recover(RoleMemento roleMemento) {
        this.defense = roleMemento.getDefense();
        this.blood = roleMemento.getBlood();
        this.attack = roleMemento.getAttack();
    }

}
